﻿namespace Digitalmes.Application.Sys.Menus.Queries;

/// <summary>
/// 查询菜单命令。
/// </summary>
public record GetMenuListQuery : IRequest<IResult<List<SysMenuDto>>>;

internal sealed class GetMenuListQueryHandler(IRepository<SysMenu> repo) : IRequestHandler<GetMenuListQuery, IResult<List<SysMenuDto>>>
{
    public async Task<IResult<List<SysMenuDto>>> Handle(GetMenuListQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetListAsync(cancellationToken);
        return Result.From(items.Adapt<List<SysMenuDto>>());
    }
}
